<template>
  <div>
    <el-card>
      <el-button type="success" @click="goBack" style="margin: 0px 0 30px 0"
        >返回</el-button
      >
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="fitNuber" label="配件数量" width="180">
        </el-table-column>
        <el-table-column prop="fitName" label="配件名称" width="180">
        </el-table-column>
        <el-table-column prop="fitPrice" label="	配件价格"> </el-table-column>

        <el-table-column prop="fitImg" label="配件缩略图">
          <template slot-scope="scoped">
            <div>
              <viewer>
                <img
                  :src="scoped.row.fitImg"
                  alt=""
                  style="width: 50px; height: 50px"
                />
              </viewer>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="fitImgs" label="	配件详细图">
          <template slot-scope="scoped">
            <div>
              <viewer>
                <img
                  v-for="(item, index) in scoped.row.fitImgs"
                  :src="item"
                  :key="index"
                  alt=""
                  style="width: 50px; height: 50px"
                />
              </viewer>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="fitadd_timeImgs" label="	添加时间">
        </el-table-column>

        <el-table-column prop="workOrderNumber" label="		告警单号">
        </el-table-column>
      </el-table>
      <div class="pagination" style="margin-bottom: 20px">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="fitform.pageSize"
          :current-page="fitform.pageNumber"
          layout="total, sizes, prev, pager, next, jumper"
          :total="count"
          class="management_page"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import { warIdGetFitList } from "../../utils/api";

export default {
  data() {
    return {
      tableData: [],
      fitform: {
        pageNumber: 1,
        pageSize: 10,
        warningId: "",
      },
      count: 0,
    };
  },
  created() {
    this.fitform.warningId = window.sessionStorage.getItem("orderId");
    this.handlerwarIdGetFitList();
  },
  methods: {
    handlerwarIdGetFitList() {
      this.postRequest(warIdGetFitList, this.fitform).then((res) => {
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.count = res.data.count;
        }
      });
    },
    goBack() {
      this.$store.dispatch("delVisitedViews", this.$route).then((obj) => {
        this.$router.push("/MaintenanRecords");
      });
      window.sessionStorage.removeItem("orderId");
    },
    // 分页
    handleSizeChange(val) {
      this.fitform.pageSize = val;
      this.getrepairSearch();
    },
    handleCurrentChange(val) {
      this.fitform.pageNumber = val;
      this.getrepairSearch();
    },
  },
};
</script>

<style>
</style>